package server;

import java.util.HashMap;
import java.util.Map;

public class QueryParser {

    public static Map<String, String> parseQueryString(String query) {
        Map<String, String> queryParams = new HashMap<>();
        if (query != null && !query.isEmpty()) {
            String[] pairs = query.split("&");
            for (String pair : pairs) {
                int idx = pair.indexOf("=");
                // 简单处理，未考虑URL解码等情况
                queryParams.put(idx > 0 ? pair.substring(0, idx) : pair, idx > 0 && pair.length() > idx + 1 ? pair.substring(idx + 1) : "");
            }
        }
        return queryParams;
    }
}
